const kafka = require("kafka-node")

const client = new kafka.Client('10.8.8.33:2181/');

const topics = [
    {
        topic: "test"
    }
];
const options = {
    autoCommit: true,
    fetchMaxWaitMs: 1000,
    fetchMaxBytes: 1024 * 1024,
    encoding: "buffer"
};

const consumer = new kafka.HighLevelConsumer(client, topics, options);

consumer.on("message", function(message) {

  var buf = new Buffer(message.value, "binary"); 

  console.log('onmessage',  buf.toString())
 
});

consumer.on("error", function(err) {
    console.log("error", err);
});

process.on("SIGINT", function() {
    consumer.close(true, function() {
        process.exit();
    });
});